/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.util.ArrayList;

/**
 *
 * @author HaTschE
 */
public class Sort {

    private ArrayList<Double> numbers;
    private int index=0;
    private double value;

    public int sort(ArrayList<Double> numbers, double value) {
        this.numbers = numbers;
        this.value = value;
        return failSort();
    }

    public void quicksort(int low, int high) {
        int i = low, j = high;
        double pivot = numbers.get(low + (high - low) / 2);
        if (high == pivot) {
            index = low;
        } else {
            if (value < pivot) {
                quicksort(low, low + (high - low) / 2);
            } else {
                quicksort(low + (high - low) / 2, high);
            }
        }
    }

    private int failSort() {
        for (int i = 0; i < numbers.size(); i++) {
            if (numbers.get(i) <= value) {
                index = i;
                return index;
            }
        }return index;
    }
}
